package com.jiepos.mpos.common.dao;

import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.stereotype.Repository;

import com.jiepos.mpos.common.constant.DBConstant;
import com.jiepos.mpos.common.constant.SystemConstant;
import com.jiepos.mpos.common.entity.App_Message_InfEntity;
import com.jiepos.mpos.core.dao.BaseDao;

@Repository
public class MessageInfDao extends BaseDao<App_Message_InfEntity> {

    /**
     * 批量修改业务状态
     * @param param
     * @param publish_st
     * @param message_uuids
     * @param updateuser
     */
        public void updateByIds(String param, String message_uuids, String publish_st, String updateuser) {
        final String[] ids = message_uuids.split(",");
        String sql = " UPDATE " + DBConstant.Table.T_APP_MESSAGE_INF + " SET PUBLISH_ST='"
                + publish_st + "' , REC_UPD_TS=SYSTIMESTAMP ,rec_upd_usr_id='"+updateuser+"', last_oper_in='" + SystemConstant.OPER_UPDATE
                + "' WHERE " + param + " = ?";
        log.debug("updateByIds sql : " + sql);
        log.debug("updateByIds ids: " + ids);
        jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
            @Override
            public int getBatchSize() {
                return ids.length;
            }
            @Override
            public void setValues(PreparedStatement arg0, int arg1) throws SQLException {
                arg0.setString(1, ids[arg1]);
            }
        });

    }
}
